package org.example.im.client.console.impl;

import io.netty.channel.Channel;
import org.example.im.bean.protocol.CommandType;
import org.example.im.bean.protocol.request.Send2GroupRequestPacket;
import org.example.im.client.console.ConsoleCommand;
import org.springframework.stereotype.Component;

import java.util.Scanner;

/**
 * @author dingrui
 * @since 2022/2/12
 * @description
 */
@Component
public class Send2GroupCommand implements ConsoleCommand {

    @Override
    public CommandType genType() {
        return CommandType.SEND_2_GROUP_REQUEST;
    }

    @Override
    public void exec(Scanner s, Channel c) {
        System.out.println("[C-Send2Group] 群发消息 群id:");
        String groupId = s.nextLine();
        System.out.println("[C-Send2Group] 消息内容:");
        String msg = s.nextLine();
        Send2GroupRequestPacket request = Send2GroupRequestPacket.builder().toGroupId(groupId).msg(msg).build();
        c.writeAndFlush(request);
    }
}
